const state = {
	 session_key:uni.getStorageSync('session_key')||'',
	 token: uni.getStorageSync('token')||'',
	 hasLogin: uni.getStorageSync('hasLogin')||false,
	 hasAuth: uni.getStorageSync('hasAuth')||false,
	 code: false,
	 hasSigned: uni.getStorageSync('hasSigned')||false,
	 userInfo: uni.getStorageSync('userInfo')||false,
	 account: uni.getStorageSync('account')||{},
	 user_id: uni.getStorageSync('user_id')||'',
	 _openid: uni.getStorageSync('_openid')||'',
	 _unionid: uni.getStorageSync('_unionid')||'',
	 notLogin: uni.getStorageSync('notLogin')||true
};
const mutations = {
	SET_SIGN: (state,hasSigned) => {
		state.hasSigned = hasSigned
		uni.setStorageSync('hasSigned', hasSigned)
	},
	SET_NOT_LOGIN: (state,notLogin) => {
		state.notLogin = notLogin
		uni.setStorageSync('notLogin', notLogin)
	},
	SET_AUTH: (state) => {
		state.hasAuth = true
		uni.setStorageSync('hasAuth', true)
	},
	SET_USER_ACCOUNT: (state,account) => {
		uni.setStorageSync('account', account)
	},
	SET_SESSION_KEY: (state,session_key) => {
		state.session_key = session_key
		uni.setStorageSync('session_key', session_key)
	},
	SET_TOKEN: (state,token) => {
		state.token = token
		uni.setStorageSync('token', token)
	},
	REMOVE_TOKEN: (state) => {
		state.token = ''
		state.session_key = ''
		state.userInfo = {}
		state.hasAuth = false
		state.hasLogin = false
		state.user_id = false
		state._unionid = false
		state._openid = false
		uni.removeStorageSync('session_key')
		uni.removeStorageSync('token')
		uni.removeStorageSync('userInfo')
		uni.removeStorageSync('hasAuth')
		uni.removeStorageSync('hasLogin')
		uni.removeStorageSync('user_id')
		uni.removeStorageSync('_openid')
		uni.removeStorageSync('_unionid')
		uni.removeStorageSync('hasSigned')
		uni.removeStorageSync('luckyShareInfo')
		uni.removeStorageSync('account')
		uni.removeStorageSync('notLogin')
		uni.removeStorageSync('login_timestamp')
	},
	SET_WX_USER: (state, {
		_openid,
		_unionid,
	}) => {
		state._openid = _openid
		state._unionid = _unionid
		uni.setStorageSync('_openid', _openid)
		uni.setStorageSync('_unionid', _unionid)
	},
	SET_USER_INFO: (state, {
		userInfo
	}) => {
		state.userInfo = userInfo
		uni.setStorageSync('userInfo', userInfo)
	},
	SET_USER_ACCOUNT: (state, {
		account
	}) => {
		state.account = account
		uni.setStorageSync('account', account)
	},
	SET_LOGIN_DATA: (state, {
		user_id,
		token,
		userInfo
	}) => {
		state.hasLogin = true
		state.hasAuth = true
		state.user_id = user_id
		state.token = token
		state.userInfo = userInfo
		uni.setStorageSync('userInfo', userInfo)
		uni.setStorageSync('user_id', user_id)
		uni.setStorageSync('hasAuth', true)
		uni.setStorageSync('hasLogin', true)
		uni.setStorageSync('token', token)
	}
};
const actions = {
	
};

const getters = {
	token: (state) => state.token
};
export default {
	namespaced: true, // 启用命名空间
	state,
	mutations,
	actions,
	getters
};